package top.vanchor.flexible.config.consts;

import org.springframework.beans.factory.annotation.Value;
import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.stereotype.Component;

/**
 * Created by IntelliJ IDEA.
 *
 * @Author : Ding
 * @create 2022/8/9 9:29
 */
@Component
@ConfigurationProperties(prefix = "spring")
public class RedisConst {

    @Value("${spring.redis.port}")
    public void setPort(String port) {
        RedisConst.PORT = Integer.parseInt(port);
    }

    @Value("${spring.redis.password}")
    public void setPassword(String password) {
        RedisConst.PASSWORD = password;
    }

    @Value("${spring.redis.host}")
    public void setHost(String host) {
        RedisConst.HOST = host;
    }

    @Value("${spring.redis.timeout}")
    public void setTimeout(String timeout) {
        RedisConst.TIMEOUT = Integer.parseInt(timeout);
    }

    @Value("${spring.redis.database}")
    public void setDatabase(String database) {
        RedisConst.DATABASE = Integer.parseInt(database);
    }

    @Value("${spring.redis.jedis.pool.max-idle}")
    public void setMaxIdle(String maxIdle) {
        RedisConst.MAX_IDLE = Integer.parseInt(maxIdle);
    }

    @Value("${spring.redis.jedis.pool.max-wait}")
    public void setMaxWait(String maxWait) {
        RedisConst.MAX_WAIT = Integer.parseInt(maxWait);
    }

    @Value("${spring.redis.jedis.pool.max-active}")
    public void setMaxActive(String maxActive) {
        RedisConst.MAX_ACTIVE = Integer.parseInt(maxActive);
    }

    @Value("${spring.redis.jedis.pool.min-idle}")
    public void setMinIdle(String minIdle) {
        RedisConst.MIN_IDLE = Integer.parseInt(minIdle);
    }

    /**
     * 端口号
     */
    public static Integer PORT;

    /**
     * 密码
     */
    public static String PASSWORD;

    /**
     * ip
     */
    public static String HOST;

    /**
     * ip
     */
    public static Integer TIMEOUT;

    /**
     * 数据库0~16
     */
    public static Integer DATABASE;

    /**
     * 最大空间数
     */
    public static Integer MAX_IDLE;

    /**
     * 最大连接数
     */
    public static Integer MAX_ACTIVE;

    /**
     * 最小空闲数
     */
    public static Integer MIN_IDLE;

    /**
     * max-wait
     */
    public static Integer MAX_WAIT;
}
